package com.felight.ems.collections;

import java.util.*;

class Employee implements Comparable<Employee> {
	Integer id;
	private String name;
	String address;
	Character gender;
	
	public String getName(){
		return name;
	}
	public Integer getId(){
		return id;
	}
	public String getAddress(){
		return address;
	}
	public Character getGender(){
		return gender;
	}

	public Employee(int id,String name,String address,char gender){
		this.id=id;
		this.name=name;
		this.address=address;
		this.gender=gender;
	}
	public String toString(){
		return this.id+"\t"+this.name+"\t"+this.gender+"\t"+this.address;
		//return (Integer.toString(id));
		
	}
	//call any one return statement according to the requirement.
	public int compareTo(Employee e){
		//return name.compareTo(e.getName());
		//return id.compareTo(e.getId());
		//return address.compareTo(e.getAddress());
		return gender.compareTo(e.getGender());
	}
	
	public static void main(String[] args){
		ArrayList<Employee> empList = new ArrayList<Employee>();
		empList.add(new Employee(06,"G","Vijayanagar",'M'));
		empList.add(new Employee(05,"U","ChandraLayout",'F'));
		empList.add(new Employee(07,"C","Banashankari",'F'));
		empList.add(new Employee(02,"A","K.R.Market",'M'));
		System.out.println("The Unsorted list of employee:"+empList);
		Collections.sort(empList);
		System.out.println("The sorted list of employee:"+empList);
	}
}
